<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>内容生成器</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        }

        /* 遮罩层 */
        .overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1;
        }

        /* 弹窗样式 */
        .modal {
            display: none;
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: #fff;
            padding: 20px;
            box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
            z-index: 2;
            width: 300px;
            text-align: center;
        }

        /* 关闭按钮 */
        .close-btn {
            background-color: #f44336;
            color: white;
            border: none;
            padding: 5px 10px;
            cursor: pointer;
            border-radius: 5px;
        }

        .close-btn:hover {
            background-color: #d32f2f;
        }

        body {
            padding: 20px;
            background: #fff;
            display: flex;
            gap: 20px;
            min-height: 100vh;
        }

        .left-panel {
            width: 300px;
            flex-shrink: 0;
        }

        .input-label {
            font-size: 14px;
            color: #333;
            margin-bottom: 10px;
        }

        textarea {
            width: 100%;
            height: 200px;
            padding: 12px;
            border: 1px solid #d9d9d9;
            border-radius: 8px;
            resize: none;
            font-size: 14px;
            margin-bottom: 20px;
            line-height: 1.6;
        }

        textarea:focus {
            outline: none;
            border-color: #1890ff;
            box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
        }

        .generate-btn {
            background: #1890ff;
            color: white;
            border: none;
            padding: 8px 24px;
            border-radius: 6px;
            font-size: 14px;
            cursor: pointer;
            transition: background 0.3s;
        }

        .generate-btn:hover {
            background: #40a9ff;
        }

        .right-panel {
            flex: 1;
            background: #e6f7ff;
            border-radius: 12px;
            padding: 20px;
            min-height: 500px;
        }

        .content-title {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 16px;
            color: #333;
        }

        .content-text {
            font-size: 14px;
            line-height: 1.8;
            color: #333;
        }
    </style>
    <script src="qrc:///qtwebchannel/qwebchannel.js"></script>
</head>
<body>
<div id="overlay" class="overlay" onclick="closeModal()"></div>

<div id="modal" class="modal">
    <p id="message">消息弹窗</p>
    <!-- TODO: 调整消息弹窗样式 -->
    <button class="close-btn" onclick="closeModal()">关闭</button>
</div>

<div class="left-panel">
    <div class="input-label">请输入文案内容:</div>
    <label for="inputText"></label><textarea id="inputText" placeholder="请输入文案或粘贴链接"></textarea>
    <button class="generate-btn" onclick="generateContent()">立即生成</button>
</div>

<div class="right-panel">
    <div class="content-title">文章标题</div>
    <div class="content-text" id="outputContent">
    </div>
</div>

<script type="text/javascript">
    document.addEventListener('DOMContentLoaded', function () {
        new QWebChannel(parent.qt.webChannelTransport, function (channel) {
            Bridge = channel.objects.Bridge;

            Bridge.result.connect(function (content) {
                // TODO: 显示结果标题
            })
            Bridge.started.connect(function (msg) {
                showModal(msg)
            });
            Bridge.finished.connect(function (msg) {
                showModal(msg)
            });
            Bridge.failed.connect(function (msg) {
                showModal(msg)
            });

            window.generateContent = function () {
                let desc = document.getElementById("inputText").value;
                if (!desc || desc.trim() === '') {
                    showModal("请输入内容");
                    return;
                }
                Bridge.general_write("rewrite", "content", desc);
            }
        });
        window.showModal = function (message) {
            document.getElementById("message").innerText = message;
            document.getElementById("overlay").style.display = "block";
            document.getElementById("modal").style.display = "block";
        };

        window.closeModal = function () {
            document.getElementById("overlay").style.display = "none";
            document.getElementById("modal").style.display = "none";
        };
    });
</script>
</body>
</html> 